home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _5A30DC0B41734B1EB49936A6F9DD1E1D < prev    next >
Encoding:
Text File  |  2004-01-06  |  6.5 KB  |  169 lines

  1. --------------------------------------------------
  2. --   Created By: Sten
  3. --   Description: Rear Threatened Behaviour
  4. --------------------------
  5.  
  6. AIBehaviour.MutantRearThreatened = {
  7.     Name = "MutantRearThreatened",
  8.  
  9.     ---------------------------------------------
  10.     OnSpawn = function( self, entity )
  11.         -- called when enemy spawned or reset
  12.     end,
  13.     ---------------------------------------------
  14.     OnActivate = function( self, entity )
  15.         -- called when enemy receives an activate event (from a trigger, for example)
  16.     end,
  17.     ---------------------------------------------
  18.     OnNoTarget = function( self, entity )
  19.         -- called when the enemy stops having an attention target
  20.     end,
  21.     ---------------------------------------------
  22.     OnBored = function( self, entity )
  23.         -- called when the enemy is a little bored
  24.     end,
  25.     ---------------------------------------------        
  26.     OnPlayerSeen = function( self, entity, fDistance )
  27.         -- called when the enemy sees a living player
  28.         if (fDistance < 15) then
  29.             AI:Signal(0,1,"ON_ENEMY_TOOCLOSE",entity.id);
  30.             entity:SelectPipe(0,"rear_target2close");
  31.         else
  32.             AI:Signal(0,1,"ON_ENEMY_TARGET",entity.id);
  33.             entity:SelectPipe(0,"rear_scramble");
  34.         end
  35.         
  36.         if (AI:GetGroupCount(entity.Properties.groupid) > 1) then
  37.             AI:Signal(SIGNALFILTER_GROUPONLY, 1, "HEADS_UP_GUYS",entity.id);
  38.             entity:InsertSubpipe(0,"DropBeaconAt"); -- in PipeManagerShared.lua
  39.         end    
  40.     end,
  41.     ---------------------------------------------
  42.     OnEnemySeen = function( self, entity )
  43.         -- called when the enemy sees a foe which is not a living player
  44.     end,
  45.     ---------------------------------------------
  46.     OnFriendSeen = function( self, entity )
  47.         -- called when the enemy sees a friendly target
  48.     end,
  49.     ---------------------------------------------
  50.     OnDeadBodySeen = function( self, entity )
  51.         -- called when the enemy a dead body
  52.     end,
  53.     ---------------------------------------------
  54.     OnEnemyMemory = function( self, entity )
  55.     end,
  56.     ---------------------------------------------
  57.     OnInterestingSoundHeard = function( self, entity )
  58.         -- called when the enemy hears an interesting sound
  59.          entity:SelectPipe(0,"rear_approach_threat"); -- in PipeManagerShared.lua
  60.          entity:InsertSubpipe(0,"DropBeaconTarget"); -- in PipeManagerShared.lua
  61.     end,
  62.     ---------------------------------------------
  63.     OnThreateningSoundHeard = function( self, entity )
  64.         -- called when the enemy hears a scary sound
  65.         entity:SelectPipe(0,"rear_approach_threat"); -- in PipeManagerShared.lua
  66.         entity:InsertSubpipe(0,"DropBeaconTarget"); -- in PipeManagerShared.lua
  67.     end,
  68.     ---------------------------------------------
  69.     OnReload = function( self, entity )
  70.         -- called when the enemy goes into automatic reload after its clip is empty
  71.     end,
  72.     --------------------------------------------------
  73.     OnNoHidingPlace = function( self, entity, sender )
  74.         -- called when no hiding place can be found with the specified parameters
  75.     end,
  76.     ---------------------------------------------
  77.     OnBulletRain = function ( self, entity, sender)    
  78.         
  79.         -- DO NOT TOUCH THIS READIBILITY SIGNAL    ------------------------
  80.         AI:Signal(SIGNALID_READIBILITY, 1, "GETTING_SHOT_AT",entity.id);
  81.         ----------------------------------------------------------------
  82.         
  83.         AI:Signal(SIGNALFILTER_GROUPONLY, 1, "INCOMING_FIRE",entity.id);
  84.         
  85.         -- Make this guy alerted
  86.         entity:MakeAlerted();
  87.  
  88.         entity:SelectPipe(0,"rear_goforcover");
  89.     end,
  90.     ---------------------------------------------
  91.     OnReceivingDamage = function ( self, entity, sender)
  92.  
  93.         -- DO NOT TOUCH THIS READIBILITY SIGNAL    ------------------------
  94.         AI:Signal(SIGNALID_READIBILITY, 1, "GETTING_SHOT_AT",entity.id);
  95.         ----------------------------------------------------------------
  96.         
  97.         AI:Signal(SIGNALFILTER_GROUPONLY, 1, "INCOMING_FIRE",entity.id);
  98.         
  99.         -- Make this guy alerted
  100.         entity:MakeAlerted();
  101.         
  102.         -- the character will go into UnderFire behaviour after this function
  103.         entity:SelectPipe(0,"rear_goforcover");
  104.     end,
  105.     --------------------------------------------------
  106.     OnGrenadeSeen = function( self, entity, fDistance )
  107.         -- called when the enemy sees a grenade
  108.         --System:LogToConsole("+++++++++++++++++++++++++++OnGrenadeSeen");
  109.         entity:InsertSubpipe(0,"grenade_run_away");
  110.     end,
  111.     --------------------------------------------------
  112.     -- CUSTOM SIGNALS
  113.     --------------------------------------------------
  114.     OnGroupMemberDied = function( self, entity, sender)
  115.         -- called when a member of the group dies
  116.         --System:LogToConsole(entity:GetName().." recieved OnGroupMemberDied signal in RearIdle");
  117.         entity:MakeAlerted();
  118.                 
  119.         if (entity ~= sender) then
  120.              entity:SelectPipe(0,"rear_goforcover");
  121.         end
  122.     end,
  123.     --------------------------------------------------
  124.     OnGroupMemberDiedNearest = function ( self, entity, sender)
  125.         --System:LogToConsole(entity:GetName().." recieved OnGroupMemberDiedNearest signal in CoverIdle");
  126.  
  127.         entity:MakeAlerted();
  128.  
  129.         -- DO NOT TOUCH THIS READIBILITY SIGNAL    ---------------------------
  130.         AI:Signal(SIGNALID_READIBILITY, 1, "FRIEND_DEATH",entity.id);
  131.         -------------------------------------------------------------------
  132.         
  133.         -- bounce the dead friend notification to the group (you are going to investigate it)
  134.         AI:Signal(SIGNALFILTER_SPECIESONLY, 1, "OnGroupMemberDied",entity.id);
  135.  
  136.         entity:SelectPipe(0,"rear_goforcover");
  137.     end,
  138.     ---------------------------------------------
  139.     Cease = function( self, entity, fDistance )
  140.         entity:SelectPipe(0,"rear_cease_approach"); -- in PipeManagerShared.lua             
  141.     end,
  142.     --------------------------------------------------
  143.     ----------------- GROUP SIGNALS ------------------
  144.     --------------------------------------------------
  145.     HEADS_UP_GUYS = function (self, entity, sender)
  146.         if (entity ~= sender) then
  147.             entity:MakeAlerted();
  148.             entity:SelectPipe(0,"rear_headup");
  149.         end
  150.     end,
  151.     ---------------------------------------------
  152.     INCOMING_FIRE = function (self, entity, sender)
  153.     end,
  154.     ------------------------------------------------------------------------
  155.     ------------------------------ Animation -------------------------------
  156.     target_lost_animation = function (self, entity, sender)
  157.         local XRandom = random(1,2);
  158.         if (XRandom == 1) then
  159.             entity:StartAnimation(0,"_curious1",0);
  160.         elseif (XRandom == 2) then
  161.             entity:StartAnimation(0,"_curious2",0);
  162.         end
  163.     end,
  164.     ------------------------------------------------------------------------
  165.     confused_animation = function (self, entity, sender)
  166.         entity:StartAnimation(0,"_headscratch2",0);
  167.     end,
  168.     ------------------------------------------------------------------------
  169. }